package bcrypt;

import crypto.keypairgenerator.KeyPairGenertor;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
import java.util.Date;

public class KeyPara {

    public static void main(String[] args) throws Exception {

        System.out.println(new Date(1606182594000L));
        byte[] data = "Data Signature".getBytes();

        KeyPairGenertor keyPairGenertor2;
        KeyPairGenerator keyPairGenertor = KeyPairGenerator.getInstance("DSA");

        keyPairGenertor.initialize(1024);

        KeyPair keyPair = keyPairGenertor.generateKeyPair();

        Signature signature = Signature.getInstance(keyPairGenertor.getAlgorithm());

        signature.initSign(keyPair.getPrivate());

        signature.update(data);

        byte[] sign = signature.sign();

        //复用，调整为公钥。进行验证。
        signature.initVerify(keyPair.getPublic());

        signature.update(data);

        boolean istrue = signature.verify(sign);
    }

}
